/*
 * @Author: Baishui
 * @Date: 2021-09-13 15:30:17
 * @LastEditors: Baishui
 * @LastEditTime: 2021-10-08 15:26:29
 * @Description: file content
 */

import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import { useAppStoreWithOut } from '@/store/modules/app'
import System from './modules/system'
// import allRoutes from './allRoutes'
const routes: RouteRecordRaw[] = [...System]
// const routes: RouteRecordRaw[] = [...allRoutes]

const router = createRouter({
  history: createWebHashHistory(),
  routes,
})

const appStore = useAppStoreWithOut()

router.beforeEach(async (to, from, next) => {
  if (!appStore.menuList.length) {
    await appStore.getMenuList()
    next({
      path: to.path,
      query: to.query,
    })
    return
  }
  next()
})

export default router
